function shutdownProcess(logStr)
    global logFile DB eN UTCNOW
    
    if isempty(logStr), logStr = {''}; end
    saveLog(logStr, 'lastCall')
    
  % Try to close the DB and add note of result to the email message
    DB.close
    eN.appendMsg([DB.err{:}])
    if regexp([DB.err{:}], 'failed!')
        eN.send = 1;
    end
    
    if isa(logFile, 'fileWrapper')
      % Try to close the log file and add note of result to the email message
        logFile.close
        if logFile.err{end}
          % Closing file failed
            msg = 'ALERT: ProcessFlights exited without closing its log file.  ';
            eN.send = 1;
        else
          % Closing file succeeded
            msg = 'ProcessFlights log file closed successfully.  ';
        end
        eN.appendMsg(msg)
        eN.appendMsg([datestr(now()) ' processing finished.  '])
    end
    
    
  % Send email if send property is "ON"
    if eN.send
        if isdeployed
            if UTCNOW < datenum('2012-07-15')
                eN.mail_recip = {'dgol461@ecy.wa.gov', 'bsac461@ecy.wa.gov'};
            end
            eN.notify('ProcessFlights')
        else
            eN.notify('ProcessFlights', 'dgol461@ecy.wa.gov')
        end
    end
    
  % Exit MATLAB if this is the deployed version of the program
    if isdeployed
        exit
    end
end